﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SubstrateHelper.Helpers
{
    public static class ParseExtensions
    {
        public static UInt32 ParseUInt32(this string str)
        {
            try
            {
                return UInt32.Parse(str);
            }
            catch
            {
                return 0;
            }
        }

        public static double ParseDouble(this string str)
        {
            try
            {
                return double.Parse(str);
            }
            catch
            {
                return 0;
            }
        }

        public static int ParseInt(this string str)
        {
            try
            {
                return int.Parse(str);
            }
            catch
            {
                return 0;
            }
        }

        public static DateTime? ParseDateTimeNullable(this string str)
        {
            try
            {
                return DateTime.Parse(str);
            }
            catch
            {
                return null;
            }
        }

        public static DateTime ParseDateTime(this string str)
        {
            try
            {
                return DateTime.Parse(str);
            }
            catch
            {
                return DateTime.Now;
            }
        }
    }
}
